package com.zhang.gulimall.cart.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 整个购物车
 */
@Data
public class Cart {
    // 商品
    private List<CartItem> items;
    // 商品总数量
    private Integer countNum;
    // 商品总类型
    private Integer countType;
    // 总价格
    private BigDecimal totalAmount;
    // 减免价格
    private BigDecimal reduce;

    public Integer getCountNum() {
        countNum = 0;
        if (items != null && items.size() > 0) {
            for (CartItem item : items) {
                countNum += item.getCount();
            }
        }
        return countNum;
    }

    public Integer getCountType() {
        countType = 0;
        if (items != null && items.size() > 0) {
            countType = items.size();
        }
        return countType;
    }
}
